home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CUJ9203.ARJ / 1003034A < prev    next >
Text File  |  1992-06-02  |  1KB  |  51 lines

  1.  
  2. EXAMPLE 4 :
  3.  
  4. /****************************************************
  5. * This is an example of the array of pointers to test
  6. * objects.  It shows how the array is defined and how
  7. * it can be searched for a specific test object.  It
  8. * also shows how, once the index to the correct test 
  9. * object is found, the pointer to the test object can 
  10. * be used to invoke the object's methods.
  11. *
  12. * This code is compiled to ROM.
  13. ****************************************************/
  14.  
  15. file main.c
  16.  
  17.  
  18. extern TEST_STR test_a();
  19. extern TEST_STR test_b();
  20. extern TEST_STR test_c();
  21.  
  22. TEST_CLASS      *test;
  23. TEST_CLASS      (const *test_ptr[]) = {&test_a,
  24.                                        &test_b,
  25.                                        &test_c,
  26.                                        0};
  27.  
  28. /* assume name is a parameter set to      */
  29. /* "Test A" select the Test A test object */
  30.  
  31. test = test_ptr[0]; 
  32. while(test != 0) {
  33.    if(strcmp(test->Test_Name,name) == 0) break;
  34.    test++;
  35. }
  36.  
  37. /* and use it to run the test */
  38.      .
  39.      .
  40. test->init_object();
  41.      .
  42.      .
  43. test->process_data(params,results);
  44.      .
  45.      .
  46. test->disp_results(results);
  47.      .
  48.      .
  49.  
  50.  
  51.